package com.fub.util.database.databaseHelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class BuildingVersionsDatabaseManager extends SQLiteOpenHelper {

	public static final String TABLE_BUILDING_VERSIONS = "building_versions";
	public static final String COL_BUILDING_ID = "building_id";
	public static final String COL_VERSION = "version";
	public static final String COL_LATITUDE = "latitude";
	public static final String COL_LONGITUDE = "longitde";
	public static final int DEFAULT_BUILDING_VERSION = 0;
	private static final String DATENBANK_NAME = "building_versions.db";
	private static final int Version = 2;

	private static final String CREATE_TABLE_BUILDING_VERSIONS = String
			.format("create table %s (%s  text primary key , %s integer not null, %s real, %s real );",
					TABLE_BUILDING_VERSIONS, COL_BUILDING_ID, COL_VERSION,
					COL_LATITUDE, COL_LONGITUDE);

	public BuildingVersionsDatabaseManager(Context context) {
		super(context, DATENBANK_NAME, null, Version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_TABLE_BUILDING_VERSIONS);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_BUILDING_VERSIONS);
		onCreate(db);
	}
}
